package com.thlws.study.redismq.context;

import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author HanleyTang 2019-07-31
 */
@Component
public class RedisContext {

    private static Map<String, RedisMessageChannel> map = new HashMap<>();

    public static void bindChannel(String channel, RedisMessageChannel listener) {
        map.put(channel, listener);
    }

    public static RedisMessageChannel acquireChannel(String channel){
        return map.get(channel);
    }

    public static void unbindChannel(String key) {
        map.remove(key);
    }


    public static boolean hasChannel(String channel){
        return map.get(channel) != null;
    }

}
